package com.kmlparser;

import java.util.ArrayList;

import com.google.android.maps.GeoPoint;
import com.route.DetailedLocation;
import com.route.Route;

public class RouteHistoryParser {
    public static String markersToStringMarkers() {
	String markersInStringForm = "";
	for (GeoPoint gp : Route.markers) {
	    markersInStringForm += gp.toString() + " ";
	}
	return markersInStringForm;
	
    }
    
    public static String claimDetailReader(String routeString){
    	String tempString = "";
    	String[] tempStringArray;
    	String[] routeHistoryArray;
    	String[] tempPoint;
    	ArrayList<GeoPoint> markers = new ArrayList<GeoPoint>();
    	try{
    		if(routeString.startsWith("Success\n")){
    			tempString = routeString.replaceFirst("Success\n", "");
    			tempStringArray = tempString.split("\n");
    			com.claim.Claim.start = new DetailedLocation(tempStringArray[0], new GeoPoint(Integer.parseInt(tempStringArray[1].split(",")[0]), Integer.parseInt(tempStringArray[1].split(",")[1])), "");
    			com.claim.Claim.end = new DetailedLocation(tempStringArray[2], new GeoPoint(Integer.parseInt(tempStringArray[3].split(",")[0]), Integer.parseInt(tempStringArray[3].split(",")[1])), "");
    			com.claim.Claim.routeLength = Double.parseDouble(tempStringArray[4]);
    			routeHistoryArray = tempStringArray[5].split(" ");
    			for(int i=0;i<routeHistoryArray.length;i++){
    			    tempPoint = routeHistoryArray[i].split(",");
    			    markers.add(new GeoPoint(Integer.parseInt(tempPoint[0]), Integer.parseInt(tempPoint[1])));
    			}
    			com.claim.Claim.markers = markers;
    			//com.claim.Claim.markers
    		}
    	}catch(Exception e){
    		
    	}
		return null;
    	
    }

}
